import { _decorator, Component, Node, Size, view, screen, ResolutionPolicy, Canvas, js } from 'cc';
import { UIManager, registerUI } from './core/modules/ui/UIManager';
import { ResManager } from './core/modules/res/ResManager';
import { LoginEntry } from './GamePlay/modules/Login/LoginEntry';
import { Match3UI } from './GamePlay/modules/Match3/Match3UI';
import { PrefabCfg } from './PrefabCfg';
const { ccclass, property } = _decorator;

export const G_VIEW_SIZE = new Size(0, 0);

declare global {
    const gCtr: GCtr;
}


@ccclass('GCtr')
export class GCtr extends Component {
    public readonly res = new ResManager();
    public readonly ui = new UIManager();

    private readonly loginEntry: LoginEntry = new LoginEntry();

    public async init(canvas2d: Canvas) {
        (globalThis as any)["gCtr"] = this;

        registerUI(PrefabCfg);
        gCtr.ui.init(canvas2d);

        this.loginEntry.init();
        this.loginEntry.showLogin(async () => {
            await gCtr.res.loadBundleAsync("Match3BN");
            gCtr.ui.open(Match3UI);
        });
    }
}


